//============================================================================
//	警告: 这个文件是使用2009-8-28 17:56:54建立的IBatisNetGen.DaoImpl.cst生成的.
//				重新生成时,原先手动做的修改将会丢失.
//============================================================================
using System;
using System.Collections.Generic;
using System.Text;
using IBatisNet.DataMapper;
using Bino.ExamOnline.Components.Entitys;
using Bino.ExamOnline.Components.Interface;
using Bino.Common.TextLib;
using System.Collections;

namespace Bino.ExamOnline.DataProvider 
{	
    /// <summary>实现<see cref="ITestPaperDao"/>接口.</summary>
    public class TestPaperDataProvider : DataProviderBase, ITestPaperDao 
	{
		/// <summary>实现 <see cref="ITestPaperDao.GetTestPapersCount"/></summary>
		public int GetTestPapersCount() {
			string statementId = "TestPaper.GetTestPapersCount";
			int result = ExecuteQueryForObject<int>(statementId, null);
			return result;
		}

		/// <summary>实现 <see cref="ITestPaperDao.GetTestPaper"/></summary>
		public TestPaper GetTestPaper(Int32 testID) 
		{
			string statementId = "TestPaper.GetTestPaper";
			TestPaper result = ExecuteQueryForObject<TestPaper>(statementId, testID);
			return result;
		}

		/// <summary>实现 <see cref="ITestPaperDao.GetTestPaperWithOutLob"/></summary>
		public TestPaper GetTestPaperWithOutLob(Int32 testID) 
		{
			string statementId = "TestPaper.GetTestPaperWithOutLob";
			TestPaper result = ExecuteQueryForObject<TestPaper>(statementId, testID);
			return result;
		}

		/// <summary>实现 <see cref="ITestPaperDao.GetAllTestPapers"/></summary>
		public IList<TestPaper> GetAllTestPapers() 
		{
			string statementId = "TestPaper.GetAllTestPapers";
			IList<TestPaper> results = ExecuteQueryForList<TestPaper>(statementId, null);
			return results;
		}

		/// <summary>实现 <see cref="ITestPaperDao.GetAllTestPapersWithOutLob"/></summary>
		public IList<TestPaper> GetAllTestPapersWithOutLob()
		{
			string statementId = "TestPaper.GetAllTestPapersWithOutLob";
			IList<TestPaper> results = ExecuteQueryForList<TestPaper>(statementId, null);
			return results;
		}
	
		/// <summary>实现 <see cref="ITestPaperDao.CreateTestPaper"/></summary>
		public void CreateTestPaper(TestPaper obj)
		{
			if (obj == null) 
				return;
			string statementId = "TestPaper.CreateTestPaper";
			ExecuteInsert(statementId, obj);
		}		

		/// <summary>实现 <see cref="ITestPaperDao.DeleteTestPaper"/></summary>
		public void DeleteTestPaper(TestPaper obj) 
		{
			if (obj == null)
				return;
			string statementId = "TestPaper.DeleteTestPaper";
			ExecuteDelete(statementId, obj);
		}

		/// <summary>实现 <see cref="ITestPaperDao.DeleteTestPaperByTestID"/></summary>
		public int DeleteTestPaperByTestID(Int32 testID) 
		{
			string statementId = "TestPaper.DeleteTestPaperByTestID";
            int result = Bino.Common.TextLib.StringHelper.SafeInt(ExecuteDelete(statementId, testID).ToString(), -1);
			return result;
		}		

		/// <summary>实现 <see cref="ITestPaperDao.ReloadTestPaper"/></summary>
		public void ReloadTestPaper(TestPaper obj) 
		{
			if (obj == null) 
				return;
			string statementId = "TestPaper.GetTestPaper";
			ExecuteQueryForObject<TestPaper>(statementId, obj, obj);
		}

        /// <summary>实现 <see cref="ITestPaperDao.UpdateTestPaper"/></summary>
        public void SaveTestPaper(TestPaper obj,bool isCommit)
        {
            if (obj == null)
                return;
            string statementId;
            if(isCommit)//提交试卷
                statementId = "TestPaper.SaveTestPaper";
            else
                statementId = "TestPaper.CommitTestPaper";
            ExecuteUpdate(statementId, obj);
        }

        /// <summary>
        /// 返回试卷
        /// 未生成的生成试卷后并返回
        /// </summary>
        /// <param name="StudentID"></param>
        /// <param name="ExamID"></param>
        /// <param name="TopicTypes"></param>
        /// <param name="TopicCounts"></param>
        /// <returns></returns>
        public IList<TestPaper> MadeAndGetTestPapers(int StudentID,int ExamID,string TopicTypes,string TopicCounts )
        {
            string statementId = "TestPaper.MadeAndGetTestPapers";
            Hashtable has = new Hashtable();            
            has.Add("StudentID", StudentID);
            has.Add("ExamID", ExamID);
            has.Add("TopicTypes", TopicTypes);
            has.Add("TopicCounts", TopicCounts);
            has.Add("returnValue", "0");//返回值 1成功;-1失败
            IList<TestPaper> results = ExecuteQueryForList<TestPaper>(statementId, has);
            return results;
        }

	}
}
